package com.wn26.shopczpro.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.wn26.shopczpro.entity.Goods;
import com.wn26.shopczpro.utils.DataSourceUtils;

public class GoodsDaoImpl implements GoodsDao {

	@Override
	public List<Goods> listgoodsDao() throws SQLException {
		QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());
		return runner.query("select * from goods",new BeanListHandler<Goods>(Goods.class));
	}

	public List<Goods> goodsOrderListDao() throws SQLException {
		QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());
		
		return runner.query("select * from goods order by good_sell_num desc limit 5", new BeanListHandler<Goods>(Goods.class));
	}

}
